<template>
	<view class="wrap">
		<view class="topBc"></view>
		<view class="content formWrap">
			<view class="title" style="margin-top: 0;display: flex; align-items: center;">
				<view style="margin-right: 12rpx;">资产总额</view>
				<u-icon name="question-circle" :color="bgColor" size="34rpx"
					@click="$util.showModal({content:`与会计准则中资产负债表的概念一致，填写截至报告年度年末，资产负债表上记录的资产总额，包括流动资产和非流动资产。`})"
				></u-icon>
			</view>
			<u-form :model="formData" ref="uForm" :rules="rules">
				西夏区燕葆花半里 v-if="formKeys.currentassets" label="流动资产" prop="currentassets" required label-width="auto" borderBottom>
					<u-input v-model="formData.currentassets" placeholder="请输入" border="none" inputAlign="right">
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				<u-form-item v-if="formKeys.noncurrentassets" label="非流动资产" prop="noncurrentassets" required label-width="auto" borderBottom>
					<u-input v-model="formData.noncurrentassets" placeholder="请输入" border="none" inputAlign="right">
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				
				<view class="title">流动资产</view>
				<u-form-item v-if="formKeys.othereceivables" label="其他应收款" prop="othereceivables" required label-width="auto" borderBottom>
					<u-input v-model="formData.othereceivables" placeholder="请输入" border="none" inputAlign="right">
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				
				<view class="title">非流动资产</view>
				<u-form-item v-if="formKeys.loequinv" label="长期股权投资" prop="loequinv" required label-width="auto" borderBottom>
					<u-input v-model="formData.loequinv" placeholder="请输入" border="none" inputAlign="right">
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				<u-form-item v-if="formKeys.netfixassets" label="固定资产" prop="netfixassets" required label-width="auto" borderBottom>
					<u-input v-model="formData.netfixassets" placeholder="请输入" border="none" inputAlign="right">
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				<u-form-item v-if="formKeys.intass" label="无形资产" prop="intass" required label-width="auto" borderBottom>
					<u-input v-model="formData.intass" placeholder="请输入" border="none" inputAlign="right">
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				
				<view class="title" style="display: flex; align-items: center;">
					<view style="margin-right: 12rpx;">负债总额</view>
					<u-icon name="question-circle" :color="bgColor" size="34rpx"
						@click="$util.showModal({content:`与会计准则中资产负债表的概念一致，填写截至报告年度年末，资产负债表上记录的负债总额，包括流动负债和非流动负债。`})"
					></u-icon>
				</view>
				<u-form-item v-if="formKeys.fordividend" label="流动负债" prop="fordividend" required label-width="auto" borderBottom>
					<u-input v-model="formData.fordividend" placeholder="请输入" border="none" inputAlign="right">
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				<u-form-item v-if="formKeys.noncurrentliabilities" label="非流动负债" prop="noncurrentliabilities" required label-width="auto" borderBottom>
					<u-input v-model="formData.noncurrentliabilities" placeholder="请输入" border="none" inputAlign="right">
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				
				<view class="title">流动负债</view>
				<u-form-item v-if="formKeys.fordividend" label="应付外方股利" prop="fordividend" required label-width="auto" borderBottom>
					<u-input v-model="formData.fordividend" placeholder="请输入" border="none" inputAlign="right">
						<view
							slot="prefix" style="transform: translateX(-12rpx);"
							@click="$util.showModal({content: `填写截至报告年度年末，外商投资企业(机构) 已宣告分配但尚未支付给外方的股利(未扣除应代扣代缴的税款。`})"
						>
							<u-icon name="question-circle" :color="bgColor" size="34rpx"></u-icon>
						</view>
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				<u-form-item v-if="formKeys.otherpayables" label="其他应付款" prop="otherpayables" required label-width="auto" borderBottom>
					<u-input v-model="formData.otherpayables" placeholder="请输入" border="none" inputAlign="right">
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				
				<view class="title" style="display: flex; align-items: center;">
					<view style="margin-right: 12rpx;">所有者权益合计</view>
					<u-icon name="question-circle" :color="bgColor" size="34rpx"
						@click="$util.showModal({content:`与会计准则中资产负债表的概念一致，填写截至报告年度年末，资产负债表
						上记录的所有者权益，包括实收资本、资本公积、盈余公积、未分配利润等。`})"
					></u-icon>
				</view>
				<u-form-item v-if="formKeys.reccap" label="实收资本" prop="reccap" required label-width="auto" borderBottom>
					<u-input v-model="formData.reccap" placeholder="请输入" border="none" inputAlign="right">
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				<u-form-item v-if="formKeys.capre" label="资本公积" prop="capre" required label-width="auto" borderBottom>
					<u-input v-model="formData.capre" placeholder="请输入" border="none" inputAlign="right">
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				<u-form-item v-if="formKeys.surpres" label="盈余公积" prop="surpres" required label-width="auto" borderBottom>
					<u-input v-model="formData.surpres" placeholder="请输入" border="none" inputAlign="right">
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				<u-form-item v-if="formKeys.undisprofit" label="未分配利润" prop="undisprofit" required label-width="auto" borderBottom>
					<u-input v-model="formData.undisprofit" placeholder="请输入" border="none" inputAlign="right">
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				<u-form-item v-if="formKeys.other" label="其他" prop="other" required label-width="auto" borderBottom>
					<u-input v-model="formData.other" placeholder="请输入" border="none" inputAlign="right">
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				<u-form-item v-if="formKeys.invsequity" label="归属于外方股东的权益" prop="invsequity" required label-width="auto" borderBottom>
					<u-input v-model="formData.invsequity" placeholder="请输入" border="none" inputAlign="right">
						<view
							slot="prefix" style="transform: translateX(-12rpx);"
							@click="$util.showModal({content: `填写截至报告年度年末，按股权比例或约定比例(符合相关法律法规的规定)计算确定的外方股东应享有的所有者权益，
							包括实收资本、资本公积、盈余公积和未分配利润等。`})"
						>
							<u-icon name="question-circle" :color="bgColor" size="34rpx"></u-icon>
						</view>
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				
				<view class="title">归属于外方股东的权益</view>
				<u-form-item v-if="formKeys.forreccap" label="实收资本" prop="forreccap" required label-width="auto" borderBottom>
					<u-input v-model="formData.forreccap" placeholder="请输入" border="none" inputAlign="right">
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				<u-form-item v-if="formKeys.forcapre" label="资本公积" prop="forcapre" required label-width="auto" borderBottom>
					<u-input v-model="formData.forcapre" placeholder="请输入" border="none" inputAlign="right">
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				<u-form-item v-if="formKeys.forsurpres" label="盈余公积" prop="forsurpres" required label-width="auto" borderBottom>
					<u-input v-model="formData.forsurpres" placeholder="请输入" border="none" inputAlign="right">
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				<u-form-item v-if="formKeys.forundisprofit" label="未分配利润" prop="forundisprofit" required label-width="auto" borderBottom>
					<u-input v-model="formData.forundisprofit" placeholder="请输入" border="none" inputAlign="right">
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				<u-form-item v-if="formKeys.forother" label="其他" prop="forother" required label-width="auto" borderBottom>
					<u-input v-model="formData.forother" placeholder="请输入" border="none" inputAlign="right">
						<view class="units_suffix" slot="suffix">
							<text><text class="units_suffix_colorRed">万</text>(元)</text>
						</view>					</u-input>
				</u-form-item>
				
			</u-form>
			
		</view>
		<view class="submitBtn_bc"></view>
		<view class="submitBtn_ubtn">
			<u-button :disabled="!$util.submitState(year,state)" @click="submit()">提交</u-button>
		</view>
	</view>
</template>

<script>
export default {
	data(){
		return{
			minFormName: 'assetsLiabilitiesinfo', //小表单类型名
			regnoInfo: this.$store.state.regnoInfo,
			year: '',
			state: '',
			bgColor: this.$config.bgColor,
			
			formData: {
				currentassets: '',
				noncurrentassets: '',
				othereceivables: '',
				loequinv: '',
				netfixassets: '',
				
				intass: '',
				fordividend: '',
				noncurrentliabilities: '',
				otherpayables: '',
				reccap: '',
				
				capre: '',
				surpres: '',
				undisprofit: '',
				other: '',
				invsequity: '',
				
				forreccap: '',
				forcapre: '',
				forsurpres: '',
				forundisprofit: '',
				forother: '',
			},
			rules: {},
			rulesAll: {
				currentassets: this.$typeData.ruleData.moneyRule,
				noncurrentassets: this.$typeData.ruleData.moneyRule,
				othereceivables: this.$typeData.ruleData.moneyRule,
				loequinv: this.$typeData.ruleData.moneyRule,
				netfixassets: this.$typeData.ruleData.moneyRule,
				
				intass: this.$typeData.ruleData.moneyRule,
				fordividend: this.$typeData.ruleData.moneyRule,
				noncurrentliabilities: this.$typeData.ruleData.moneyRule,
				otherpayables: this.$typeData.ruleData.moneyRule,
				reccap: this.$typeData.ruleData.moneyRule,
				
				capre: this.$typeData.ruleData.moneyRule,
				surpres: this.$typeData.ruleData.moneyRule,
				undisprofit: this.$typeData.ruleData.moneyRule,
				other: this.$typeData.ruleData.moneyRule,
				invsequity: this.$typeData.ruleData.moneyRule,
				
				forreccap: this.$typeData.ruleData.moneyRule,
				forcapre: this.$typeData.ruleData.moneyRule,
				forsurpres: this.$typeData.ruleData.moneyRule,
				forundisprofit: this.$typeData.ruleData.moneyRule,
				forother: this.$typeData.ruleData.moneyRule,
			},
			formKeys: {},
		}
	},
	onLoad(option) {
		this.year = option.year;
		this.state = option.state;
		this.getFormKey();
		this.getFormData();
	},
	onReady() {
		this.$refs.uForm.setRules(this.rules)
	},
	methods:{
		// 获取小表单数据
		getFormData(){
			let url = this.$typeData.minFormUrl.get(this.minFormName);
			if(!url){
				uni.showModal({
					title: '暂无接口'
				})
				return;
			}
			this.$http.sendRequest({
				url: url,
				data: {
					regno: this.regnoInfo.regno,
					ancheyear: this.year
				}
			})
			.then(res=>{
				console.log('接口返回',res.data);
				let data = res.data;
				let keys = Object.keys(this.formKeys);				keys.forEach(item=>{					this.formData[item] = data[item];				})
				console.log(789789,this.formData);
			})
			.catch(err=>{})
		},
		//获取小表单拥有字段
		getFormKey(){
			let formKeys = this.$util.getFormKeys(this.minFormName,this.regnoInfo.enttype);
			this.formKeys = formKeys;
			let keys = Object.keys(formKeys);
			keys.forEach(item=>{
				this.rules[item] = this.rulesAll[item];
			})
		},
		submit(){
			this.$refs.uForm.validate().then(res => {
				this.saveBtn();
			}).catch(errors => {
				this.$util.showToast({title:'请完善信息'})
			})
		},
		saveBtn(){
			let data = {
				regno: this.regnoInfo.regno,
				ancheyear: this.year,
			}
			data = this.$util.setSaveFormData(this.formKeys,data,this.formData);
			this.$http.sendRequest({
				url: '/annual/report/ws-baseinfo/update-wsassetsliabilitiesinfo',
				method: 'PUT',
				data: data
			})
			.then(res=>{
				this.setRecord();
			})
			.catch(err=>{})
		},
		
		
		
		
		
		//存一下记录
		setRecord(){
			let fillingItem = this.$minFormType.get(this.minFormName);
			this.$http.sendRequest({
				url: '/annual/report/record',
				method: 'POST',
				data: {
					regno: this.regnoInfo.regno,
					year: this.year,
					fillingItem: fillingItem,
					isImp: '0',
				},
				hideLoad: true,
			})
			.then(res=>{
				uni.navigateBack();
			})
			.catch(err=>{})
		},
		goPage(path){
			uni.navigateTo({
				url: path
			})
		},
	}
}
</script>

<style lang="less" scoped>
.wrap{
	width: 100vw;
	min-height: 100vh;
	padding-top: 16rpx;
	box-sizing: border-box;
	position: relative;
	background-color: #FFF;
	
	.topBc{
		height: 10rpx;
		background-color: #F5F6F8;
	}
}

.content{
	padding: 30rpx 36rpx;
	background-color: #FFF;
	
	.title{
		color: #E4B269;
		font-size: 36rpx;
		font-weight: bold;
		border-left: 8rpx solid #E4B269;
		line-height: 40rpx;
		padding-left: 16rpx;
		margin-bottom: 30rpx;
		margin-top: 30rpx;
	}
	
	
}
</style>